﻿namespace StringBuilderSubstringTest
{
    using System;
    using System.Text;
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using _01.StringBuilderSubstring;

    [TestClass]
    public class StringBuilderSubstringTest
    {
        [TestMethod]
        public void TestWithZeroIndex()
        {
            string exampleText = "Until you stand before death so now you can create";
            StringBuilder exampleTextStringBuilder = new StringBuilder(exampleText);
            Assert.AreEqual(exampleText.Substring(0), exampleTextStringBuilder.Substring(0).ToString());
        }

        [TestMethod]
        public void TestWithIndexInTheMiddle()
        {
            string exampleText = "Until you stand before death so now you can create";
            StringBuilder exampleTextStringBuilder = new StringBuilder(exampleText);
            Assert.AreEqual(exampleText.Substring(10, 3), exampleTextStringBuilder.Substring(10, 3).ToString());
        }

        [TestMethod]
        public void TestWithIndexEqualToStringLength()
        {
            string exampleText = "Until you stand before death so now you can create";
            StringBuilder exampleTextStringBuilder = new StringBuilder(exampleText);
            Assert.AreEqual(exampleText.Substring(exampleText.Length), exampleTextStringBuilder.Substring(exampleText.Length).ToString());
        }

        [TestMethod]
        public void TestWithEmptyString()
        {
            string exampleText = string.Empty;
            StringBuilder exampleTextStringBuilder = new StringBuilder(exampleText);
            Assert.AreEqual(exampleText.Substring(0), exampleTextStringBuilder.Substring(0).ToString());
        }
    }
}
